import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:top_foundation/component/horse_race_lamp.dart';
import 'package:top_foundation/utils/theme/theme.dart';
import 'package:whale/helper/component/carousel_text.dart';
import 'package:whale/helper/component/maquee/maquee_text.dart';
import 'package:whale/helper/utils/util.dart';

import 'index.dart';
import 'widgets/widgets.dart';

class CarouselTextDemoPage extends GetView<CarouselTextDemoController> {
  const CarouselTextDemoPage({Key? key}) : super(key: key);

  // 主视图
  Widget _buildView() {
    final state = controller.state;
    return Column(
      children: [
        Padding(
          padding: EdgeInsets.symmetric(vertical: 10.r),
          child: Marquee(
            child: Text('我是一个跑马灯，哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈'),
          ),
        ),
        Card(
          child: CarouselText(
            list: state.carouselTextList,
            height: 100,
            color: ITheme.titleColor,
            onTap: (p0) {
              Hud.toast(state.carouselTextList[p0]);
            },
          ),
        ),
        MarqueeGiftView(
            itemBuilder: (context, index) {
              return Container(
                child: Row(
                  children: [
                    Icon(Icons.airplanemode_on),
                    Text('G311航班预计5月21日下午15:00准时到达，请需要登机的乘客做好准备'),
                    Icon(Icons.mood),
                  ],
                ),
              );
            },
            itemCount: 5),
      ],
    );
  }

  @override
  Widget build(BuildContext context) {
    return GetBuilder<CarouselTextDemoController>(
      builder: (_) {
        return Scaffold(
          appBar: AppBar(title: const Text("carousel_text_demo")),
          body: SafeArea(
            child: _buildView(),
          ),
        );
      },
    );
  }
}
